cmake_minimum_required(VERSION 3.30)
#message("@@@VCPKG_DEFAULT_TRIPLET->" ${VCPKG_DEFAULT_TRIPLET})
#message("@@@VCPKG_TARGET_TRIPLET->" ${VCPKG_TARGET_TRIPLET})
#message("打印环境变量->" $ENV{path})
#message("C编译器->" ${CMAKE_C_COMPILER})
#message("C++编译器->" ${CMAKE_CXX_COMPILER})
#message("buildType->" ${CMAKE_BUILD_TYPE})
#message("PROJECT_NAME->" ${PROJECT_NAME})
#message("buildType->" ${CMAKE_BUILD_TYPE})
#message("PROJECT_SOURCE_DIR->" ${PROJECT_SOURCE_DIR})
#message("CMAKE_ANDROID_ARCH_ABI->" ${CMAKE_ANDROID_ARCH_ABI})
add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
# 判断操作系统

project(mxzxFFmpeg VERSION 1.0)

# 设置全局 C 和 C++ 标准
set(CMAKE_C_STANDARD 17)
set(CMAKE_C_STANDARD_REQUIRED True)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)

aux_source_directory("cJSON" cJSONSource)
aux_source_directory("utils" utils)

#生成动态库，
add_executable(${PROJECT_NAME} main.cpp ${cJSONSource}  ${utils} FindCodec.c MxzxAudioLib.c MxzxFFmpegBase.c)
message("目标系统->" ${CMAKE_SYSTEM_NAME})
find_package(FFMPEG REQUIRED)
message("ffmpeg目录参数->" ${FFMPEG_INCLUDE_DIRS} ${FFMPEG_LIBRARY_DIRS} ${FFMPEG_LIBRARIES})
target_include_directories(${PROJECT_NAME} PRIVATE ${FFMPEG_INCLUDE_DIRS})
target_link_directories(${PROJECT_NAME} PRIVATE ${FFMPEG_LIBRARY_DIRS})
target_link_libraries(${PROJECT_NAME} PRIVATE ${FFMPEG_LIBRARIES})
if(CMAKE_BUILD_TYPE STREQUAL "Release")
    #    使用安装命令收集最终的库。到目标目录，当然也可以是Android 项目的目录里
    message("执行安装命令 安装目录->" ${PROJECT_SOURCE_DIR}/libs-${PROJECT_VERSION}/${CMAKE_ANDROID_ARCH_ABI})
    install(TARGETS ${PROJECT_NAME} DESTINATION "${PROJECT_SOURCE_DIR}/libs-${PROJECT_VERSION}/${CMAKE_ANDROID_ARCH_ABI}")
#    message("执行安装命令 安装目录->直接把so文件复制到Android的libs目录里" "D:/yuanma/CApplication/app/libs/${CMAKE_ANDROID_ARCH_ABI}")
#    install(TARGETS ${PROJECT_NAME} DESTINATION "D:/yuanma/CApplication/app/libs/${CMAKE_ANDROID_ARCH_ABI}")
endif ()